import { createStore } from 'redux';

const initialState = {
    schools: [],
    classes: [],
    students: [],
    user: null
};

const reducer = (state = initialState, action) => {
    switch(action.type) {
        case 'SET_SCHOOLS':
            return { ...state, schools: action.payload };
        case 'SET_CLASSES':
            return { ...state, classes: action.payload };
        case 'SET_STUDENTS':
            return { ...state, students: action.payload };
        case 'SET_USER':
            return { ...state, user: action.payload };
        default:
            return state;
    }
};

const store = createStore(reducer);
export default store;
